/**
 * @file main.c
 * @author your name (you@domain.com)
 * @brief 
 * @version 0.1
 * @date 2023-02-04
 * 
 * @copyright Copyright (c) 2023
 * 
 */

#include "main.h"

char *gUart_Project_Name="EP-E10A-LCD01001";    // 项目名称
uint8_t can_tx_buf[8] = {0};

int i = 0;

int main(void)
{
    /*  */
	SCB->VTOR = FLASH_BASE | 0x4000;

	/* configure systick */
	__enable_irq();
    systick_config(); 
	delay_1ms(100);
	bsp_gpio_init();
	TIMER3_Configuration();  /* 时基 */
	
	delay_1ms(300);
	LCD_Initial();  //LCD 初始化

	bsp_usart0_init(9600);  /* UART0 */

	// bsp_can_init();

	iwdg_init();
	
    _lcd_refresh_back();
    delay_1ms(300);
    LCDK_CTRL_EN;
    RS485_CTRL_EN;
    while (1) 
    {
		modbus_master_task();
		iap_task();

		if (timer_5ms_flag)
		{
			timer_5ms_flag = 0;
		}

        if (timer_200ms_flag)
        {
            timer_200ms_flag = 0;
            key_event_handle();
        }
        
		if (timer_1s_flag)
		{
			timer_1s_flag = 0;
            lcd_task();
            sleep_task();
                        
			mb_get_bms_info();
		}
	}
}
